package com.itheima.demo01.Map;

import java.util.HashMap;
import java.util.Scanner;

public class Demo06MapTest {
    public static void main(String[] args) {
        System.out.println("请输入一段字符串:");
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        HashMap<Character, Integer> map = new HashMap<>();
        char[] chars = s.toCharArray();
        for (int i = 0; i < chars.length; i++) {
            if (!map.containsKey(chars[i])) {
                map.put(chars[i], 1);
            } else {
                map.put(chars[i], map.get(chars[i])+1);
            }
        }
        System.out.println(map);
    }
}
